package com.atguigu.test;

import com.atguigu.bean.Yellow;
import com.atguigu.config.MainConfigOfProfile;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import javax.sql.DataSource;

public class IOCTest_Profile {
    //private AnnotationConfigApplicationContext context =
    //        new AnnotationConfigApplicationContext();

    private AnnotationConfigApplicationContext context =
            new AnnotationConfigApplicationContext(MainConfigOfProfile.class);

    @Test
    public void test1(){
        //ConfigurableEnvironment environment = context.getEnvironment();
        //// 设置需要激活的环境
        //environment.setActiveProfiles("test","production");
        //// 注册主配置类
        //context.register(MainConfigOfProfile.class);
        //// 启动刷新容器
        //context.refresh();
        String[] beanNamesForType = context.getBeanNamesForType(DataSource.class);
        for (String beanId : beanNamesForType) {
            System.out.println(beanId);
        }

        Yellow ye = context.getBean(Yellow.class);
        System.out.println(ye);
    }
}
